package com.caishi.lkx.exam.deserializer;

import com.caishi.lkx.exam.ienum.BaseEnum;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;

public class GenericEnumSerializer<E extends Enum<E> & BaseEnum<T>, T> extends JsonSerializer<E> {

    private final Class<E> enumClass;

    public GenericEnumSerializer(Class<E> enumClass) {
        this.enumClass = enumClass;
    }
    @Override
    public void serialize(E value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
        gen.writeNumber(String.valueOf(value.getCode()));  // 确保写入的是 code
    }
}